package com.xuhuan.axios.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author: huan.xu
 * @create: 2024/6/10 12:57
 * @description: 通用返回
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

  /**
   * 业务状态码：0-成功 1-失败
   */
  private Integer code;
  private String message;
  private T data;

  public static <E> Result<E> success(E date){
    return new Result<>(0,"操作成功",date);
  }

  public static Result success(){
    return new Result<>(0,"操作成功",null);
  }

  public static Result error(String message){
    return new Result<>(1,message,null);
  }
}
